﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL.Users.Impl;
using BLL.Users;
using Model;
using GenericLibrariesToolKit;
using Utils;

public partial class Page_Expert_ExpertOfList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
            try
            {
                if (Request.QueryString["expertName"] != null)
                {
                    
                    string expert_Name = Request.QueryString["expertName"].ToString();
                    searchExpert(expert_Name);
                }
                else
                {
                    ExpertDataBind();
                }
            }
            catch (Exception)
            { }
    }
  
    protected void LBExpertId_Click(object sender, EventArgs e)
    {        
        LinkButton btn = (LinkButton)sender;
        string expertId = btn.CommandArgument.ToString() ;
        Response.Redirect("ExpertDetails.aspx?expertId="+expertId);

    }

    private void ExpertDataBind()
    {
        ExpertBO expertBO = new ExpertBOImpl();
        QueryResult<Expert> queryExperts = expertBO.GetScrollData();
        List<Expert> listExperts = queryExperts.ResultList;
        gvExpert.DataSource = listExperts;
        gvExpert.DataBind();
    }

    //专家搜索
    private void searchExpert(string expertName)
    {
        ExpertBO expertBO = new ExpertBOImpl();
        List<Expert> experts = expertBO.GetExpertByName(expertName);
        //Response.Write("<script>alert('" + experts.Count.ToString() + "')</script>");
        if (experts.Count == 0)
            return;
        gvExpert.DataSource = experts;
        gvExpert.DataBind();
    }
    //分页处理
    protected void gvExpert_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.gvExpert.PageIndex = e.NewPageIndex;
        this.gvExpert.DataBind();
    }

    protected void btnEventsBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Write("<script language=javascript>history.go(-2);</script>");
    }
}